package algorithm.sort.array;

/**
 * @program: algorithm-data-structure
 * @description: bubbling sort method.
 * @author: Keyu Li
 * @create: 2021-08-30 09:51
 **/

public class SortSelection implements SortingMethod{
    String name = "Selection";
    @Override
    public String getName(){
        return name;
    }
    @Override
    public void sort(int[] arr){
        int temp;
        for (int i = 0; i < arr.length-1; i++) {
            int minIndex = i;
            for (int j = i+1; j < arr.length; j++) {
                if (arr[minIndex]>arr[j])
                    minIndex = j;
            }
            temp = arr[i];
            arr[i] = arr[minIndex];
            arr[minIndex] = temp;
        }
    }
}
